import 'dart:convert';
import 'dart:io';

import 'package:dbio_utils/bgzf_filehandle/unzip.dart';
import 'package:dbio_utils/generic_filehandle/local_file.dart';
import 'package:dbio_utils/tabix/chunk.dart';
import 'package:dbio_utils/tabix/virtual_offset.dart';
import 'package:flutter_test/flutter_test.dart';

main() {
  test('unzip', () async {
    var testData = File('test/bgzf/data/bgzip-1.txt.gz');
    var fileHandler = LocalFile(testData);
    var bytes = unzip(await fileHandler.readFile());
    expect(65569, bytes.length);
  });

  test('unzip chunk slice', () async {
    var testData = File('test/bgzf/data/paired.bam');
    var fileHandler = LocalFile(testData);
    // var bytes = unzip(await fileHandler.readFile());

    Chunk chunk = Chunk(VirtualOffset(0, 0), VirtualOffset(0, 100), 0);
    ChunkSlice slice = unzipChunkSlice(await fileHandler.readFile(), chunk);
    print(slice.dpositions);
    print(slice.cpositions);
  });

  test('unzip chunk slice, can unzip positive minv.dataPosition', () async {
    var testData = File('test/bgzf/data/paired.bam');
    var fileHandler = LocalFile(testData);
    // var bytes = unzip(await fileHandler.readFile());

    Chunk chunk = Chunk(VirtualOffset(0, 5), VirtualOffset(0, 100), 0);
    ChunkSlice slice = unzipChunkSlice(await fileHandler.readFile(), chunk);
    print(slice.dpositions);
    print(slice.cpositions);
  });
}
